<?php

// 会员分销表

namespace app\shop\model;

use think\Model;

class MemberDistribution extends Model
{
    //分销列表下线人和分销订单一对多
    public function memberDistributionOrder()
    {
        return $this->hasMany('MemberDistributionOrder', 'member_id', 'referrals_id');
    }

    //分销列表和会员表一对一  (分销人)
    public function member()
    {
        return $this->belongsTo('Member', 'referrals_id', 'id')->field('id,nickname,avatar,username');
    }

    //分销列表和会员多对一  (推荐人)
    public function TjMember()
    {
        return $this->belongsTo('Member', 'distribution_id', 'id')->field('id,nickname');
    }

    public function getCreateTimeAttr($value)
    {
        return date('Y-m-d', $value);
    }
}